Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add client setting for Max Range to Draw Sensor / Visual Rings #4470

Merged
merged 6 commits into from
Jun 7, 2023

Conversation

kuronekochomusuke
Copy link
Collaborator

@kuronekochomusuke kuronekochomusuke commented May 29, 2023

  • code improvements to help with lag in the case when sensor range is 1000+

fixes #4467

Copy link
Member

@NickAragua NickAragua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spelling fix. Also, discussion point: do we really need the extra setting? Why not just cap the draw range to the bigger of board width/height and call it a day? I don't think I've ever seen a board bigger than 200x200.

@kuronekochomusuke
Copy link
Collaborator Author

would just capping still lag people with slow computers on large maps? the setting allows it be be dialed back to what your computer can handle.

@SJuliez
Copy link
Member

SJuliez commented May 30, 2023

Why is it slow with sensor range 1000? Wouldn't this mean it shouldn't draw anything? Or rather, only draw sprites at the board edges (one could think about removing even this if the board edge is not actually the edge of the range)

@kuronekochomusuke
Copy link
Collaborator Author

it calculates out to max range, then removes them any not on the board, before it tries to draw anything. it grows larger the further out you are, since it adds a other circle of points each step.

I have added logic to only calculate out to max range from your position on the board, that should help.

@SJuliez
Copy link
Member

SJuliez commented May 31, 2023

I'd like to second @NickAragua suggestion to not give this a client setting if it can be avoided. The algorithm for determining the hexes to paint can be improved a lot here I think. If I'm not mistaken, the thing to draw here is a ring of hexes at the respective range, right? So the only hexes that can possibly have a sprite are those at exactly the range and those on the board edge. Those on the board edge could be omitted because that doesn't add any relevant information (obviously, any range ends at the board edge). First, check if X > board diagonal. If so, draw nothing. Otherwise, add those at range X, not all those from range 0 to X. Then remove any not on the board. Then to determine the edges to draw just compare the surrounding hexes if they're more distant than X. Unless range X = 0, only a maximum of 3 edges can ever be there. This should speed up things and I'm sure there is more potential improvement. I hope I made not too many errors in this.

@kuronekochomusuke
Copy link
Collaborator Author

with sensors currently, the start is drawn on the near side of the hex, and the end is on the far edge. this helps showing they are one range. not sure your algorithm would handle that.

also drawing the ones along the board edge help show that the two ranges are connected and the sensors are active between the two.

drawing along the board edge shows that you can see up to that edge.

Copy link
Member

@NickAragua NickAragua left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a major improvement over what was there before anyway. If the person reporting the issue is still experiencing slowness afterwards, then we can work on further improvements in the spirit of those outlined by @SJuliez, in terms of not looping through every hex on the map.

@kuronekochomusuke
Copy link
Collaborator Author

also if you turn it off, nothing will calculate now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[0.49.13] Lag when using large craft and TacOps Sensor Rules
4 participants